<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="icon" href="./assets/images/favicon.ico"/>
    <title>EasyWeb后台开发框架</title>
    <link rel="stylesheet" href="./assets/libs/layui/css/layui.css"/>
    <link rel="stylesheet" href="./assets/module/admin.css?v=307"/>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <!-- 头部 -->
    <div class="layui-header">
        <div class="layui-logo">
            <img src="assets/images/logo.png"/>
            <cite>&nbsp;EasyWeb Pro&emsp;</cite>
        </div>
        <ul class="layui-nav layui-layout-left">
            <li class="layui-nav-item" lay-unselect>
                <a ew-event="flexible" title="侧边伸缩"><i class="layui-icon layui-icon-shrink-right"></i></a>
            </li>
            <li class="layui-nav-item" lay-unselect>
                <a ew-event="refresh" title="刷新"><i class="layui-icon layui-icon-refresh-3"></i></a>
            </li>
        </ul>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item" lay-unselect>
                <a>
                    <img src="assets/images/head.png" class="layui-nav-img">
                    <cite id="huName"></cite>
                </a>
            </li>
        </ul>
    </div>

    <!-- 侧边栏 -->
    <div class="layui-side">
        <div class="layui-side-scroll">
        </div>
    </div>

    <!-- 主体部分 -->
    <div class="layui-body"></div>

    <!-- 底部 -->
    <div class="layui-footer">
        copyright © 2019 easyweb.vip all rights reserved. <span class="pull-right">Version 3.0.8</span>
    </div>
</div>

<!-- 加载动画 -->
<div class="page-loading">
    <div class="ball-loader">
        <span></span><span></span><span></span><span></span>
    </div>
</div>

<!-- 侧边栏渲染模板 -->
<script id="sideNav" type="text/html">
    {{#  layui.each(d, function(index, item){ }}
    <li class="layui-nav-item">
        <a href="{{item.url}}"><i class="layui-icon {{item.icon}}"></i>&emsp;<cite>{{ item.name}}</cite></a>
        {{# if(item.subMenus&&item.subMenus.length>0){ }}
        <dl class="layui-nav-child">
            {{# layui.each(item.subMenus, function(index, subItem){ }}
            <dd>
                <a href="{{ subItem.url }}">{{ subItem.name }}</a>

                {{# if(subItem.subMenus&&subItem.subMenus.length>0){ }}
                <dl class="layui-nav-child">
                    {{# layui.each(subItem.subMenus, function(index, thrItem){ }}
                    <dd>
                        <a href="{{ thrItem.url }}">{{ thrItem.name }}</a>

                        {{# if(thrItem.subMenus&&thrItem.subMenus.length>0){ }}
                        <dl class="layui-nav-child">
                            {{# layui.each(thrItem.subMenus, function(index, fourItem){ }}
                            <dd>
                                <a href="{{ fourItem.url }}">{{ fourItem.name }}</a>

                                {{# if(fourItem.subMenus&&fourItem.subMenus.length>0){ }}
                                <dl class="layui-nav-child">
                                    {{# layui.each(fourItem.subMenus, function(index, fiveItem){ }}
                                    <dd>
                                        <a href="{{ fiveItem.url }}">{{ fiveItem.name }}</a>
                                    </dd>
                                    {{# }); }}
                                </dl>
                                {{# } }}

                            </dd>
                            {{# }); }}
                        </dl>
                        {{# } }}

                    </dd>
                    {{# }); }}
                </dl>
                {{# } }}
            </dd>
            {{# }); }}
        </dl>
        {{# } }}
    </li>
    {{#  }); }}
</script>

<!-- js部分 -->
<script type="text/javascript" src="./assets/libs/layui/layui.js"></script>
<script>
    layui.config({
        base: 'assets/module/'
    }).extend({
        formSelects: 'formSelects/formSelects-v4',
        treetable: 'treetable-lay/treetable',
        dropdown: 'dropdown/dropdown',
        notice: 'notice/notice',
        step: 'step-lay/step',
        dtree: 'dtree/dtree',
        citypicker: 'city-picker/city-picker',
        tableSelect: 'tableSelect/tableSelect'
    }).use(['layer', 'element', 'config', 'index', 'admin', 'laytpl'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var element = layui.element;
        var config = layui.config;
        var index = layui.index;
        var admin = layui.admin;
        var laytpl = layui.laytpl;

        // 获取用户信息
        admin.req('userInfo.json', {}, function (res) {
            if (200 == res.code) {
                config.putUser(res.user);
                admin.renderPerm();  // 移除没有权限的元素
                $('#huName').text(res.user.nickName);
            } else {
                layer.msg('获取用户失败', {icon: 2});
            }
        }, 'get');

        // 加载侧边栏
        admin.req('menus-more.json?v=307', {}, function (res) {
            var headerHtml = '';
            for (var i = 0; i < res.length; i++) {
                laytpl(sideNav.innerHTML).render(res[i].subMenus, function (html) {
                    html = '<ul nav-id="' + res[i].id + '" class="layui-nav layui-nav-tree" lay-accordion="true" lay-filter="admin-side-nav">' + html;
                    html += '</ul>';
                    $('.layui-layout-admin .layui-side .layui-side-scroll').append(html);
                });
                headerHtml += '<li class="layui-nav-item" lay-unselect><a nav-bind="' + res[i].id + '">' + res[i].name + '</a></li>';
            }
            var $header = $('.layui-layout-admin .layui-header .layui-layout-left');
            $header.find('.layui-nav-bar').remove();
            $header.append(headerHtml);
            element.render('nav');
            index.regRouter(res);  // 注册路由
            index.loadHome({  // 加载主页
                url: '#/console/console1',
                name: '<i class="layui-icon layui-icon-home"></i>'
            });
        }, 'get');

        // 移除loading动画
        setTimeout(function () {
            admin.removeLoading();
        }, 300);

    });
</script>
</body>

</html>